package colopl.http.service;

import java.util.ArrayList;
import java.util.List;

import colopl.http.service.bean.LinkColony;
import colopl.http.service.bean.SouvenirCount;
import colopl.http.service.bean.WareHouseItem;

public class BeanUtil {
    
    public static List<WareHouseItem> convertWareHouseItem(List<String> autoIDs, List<String> names, int page) {
        List<WareHouseItem> list = new ArrayList<WareHouseItem>();
        
        for (int i = 0; i < autoIDs.size(); i++) {
            WareHouseItem item = new WareHouseItem();
            item.setAutoID(autoIDs.get(i));
            item.setName(names.get(i));
            item.setPageNumber(page);
            item.setLineNumber(i + 1);
            list.add(item);
        }
        
        return list;
    }
    
    public static List<LinkColony> convertLinkColony(List<String> ids, List<String> nicknames,
            String section, int groupId) {
        
        List<LinkColony> list = new ArrayList<LinkColony>();
        
        for (int i = 0; i < ids.size(); i++) {
            LinkColony link = new LinkColony();
            link.setId(Integer.valueOf(ids.get(i)));
            link.setNickname(nicknames.get(i));
            link.setSection(section);
            link.setGroupId(groupId);
            list.add(link);
        }
        
        return list;
    }
    
    public static List<SouvenirCount> convertSouvenirCount(List<String> omiyageIDs, List<String> myCounts, List<String> otherCounts, List<String> names) {
        
        List<SouvenirCount> list = new ArrayList<SouvenirCount>();
        
        for (int i = 0; i < myCounts.size(); i++) {
            SouvenirCount count = new SouvenirCount();
            count.setOmiyageID(Integer.valueOf(omiyageIDs.get(i)));
            count.setMyCount(Integer.valueOf(myCounts.get(i)));
            count.setOtherCount(Integer.valueOf(otherCounts.get(i)));
            count.setName(names.get(i));
            list.add(count);
        }
        
        return list;
    }
    
}
